/**
 * @Author: lifuzhao
 * @Date: 2019-07-12
 * @Project: driver
 */
const _fn = {
  sleep(millisecond) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, millisecond)
    })
  }
  , setTitle(title) {
    let ret = '代驾后台管理系统'
    if (title) {
      ret = title + ' | ' + ret
    }
    document.title = ret
  }
  , deepClone(obj) {
    try {
      obj = JSON.parse(JSON.stringify(obj))
    } catch (e) {
      return obj
    }
    return obj
  }
  , startFullScreen() {
    let element = document.documentElement;
    if (element.requestFullscreen) {
      element.requestFullscreen();
    } else if (element.msRequestFullscreen) {
      element.msRequestFullscreen();
    } else if (element.mozRequestFullScreen) {
      element.mozRequestFullScreen();
    } else if (element.webkitRequestFullscreen) {
      element.webkitRequestFullscreen();
    }
  }
  , endFullScreen() {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    }
  }
}
_fn.install = function (Vue) {
  Object.defineProperties(Vue.prototype, {
    fn: {
      get() {
        return _fn
      }
    },
    $fn: {
      get() {
        return _fn
      }
    },
  })
}
export default _fn
